#!/usr/bin/env bash

docker container inspect mongo > /dev/null  2>&1

if [ $? -eq 0 ]; then
		echo "skip docker mongo"
		exit
fi

host=$1
if [ -z "$host" ]
then
  host='http://dev8.cn:8000/static/ops'
fi

mkdir -p /opt/docker

wget $host/mongo-export.sh -P /opt/docker -N && \
docker cp /opt/docker/mongo-export.sh mongo:/usr/bin/mongo-export.sh && \
docker exec mongo chmod +x /usr/bin/mongo-export.sh

wget $host/mongo-import.sh -P /opt/docker -N && \
docker cp /opt/docker/mongo-import.sh mongo:/usr/bin/mongo-import.sh && \
docker exec mongo chmod +x /usr/bin/mongo-import.sh

docker volume create mongo_data

docker run --name mongo -dt -p 8017:27017  \
-e MONGO_INITDB_ROOT_USERNAME=root \
-e MONGO_INITDB_ROOT_PASSWORD=yxh123  \
-v mongo_data:/data mongo


# curl -fsSL http://dev8.cn:8000/static/ops/docker-mongo.sh | bash
